# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("//bazel:pl_build_system.bzl", "pl_boringcrypto_go_sdk", "pl_cc_test_library", "pl_go_sdk_version_template_to_label")

# TODO(vihang): load this from pl_build_system once we remove go 1.16
pl_supported_go_sdk_versions = [
    "1.17",
    "1.18",
    "1.19",
    "1.20",
]

pl_all_supported_go_sdk_versions = pl_supported_go_sdk_versions + pl_boringcrypto_go_sdk

package(default_visibility = ["//src/stirling:__subpackages__"])

pl_cc_test_library(
    name = "cassandra_container",
    srcs = [],
    hdrs = ["cassandra_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:datastax_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "curl_container",
    srcs = [],
    hdrs = ["curl_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:curl_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "dns_server_container",
    srcs = [],
    hdrs = ["dns_server_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:dns_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

[
    pl_cc_test_library(
        name = pl_go_sdk_version_template_to_label("go_%s_grpc_client_container", sdk_version),
        srcs = [],
        hdrs = [pl_go_sdk_version_template_to_label("go_%s_grpc_client_container.h", sdk_version)],
        data = [
            pl_go_sdk_version_template_to_label("//src/stirling/testing/demo_apps/go_grpc_tls_pl/client:golang_%s_grpc_tls_client.tar", sdk_version),
        ],
        deps = ["//src/common/testing/test_utils:cc_library"],
    )
    for sdk_version in pl_all_supported_go_sdk_versions
]

[
    pl_cc_test_library(
        name = pl_go_sdk_version_template_to_label("go_%s_grpc_server_container", sdk_version),
        srcs = [],
        hdrs = [pl_go_sdk_version_template_to_label("go_%s_grpc_server_container.h", sdk_version)],
        data = [
            pl_go_sdk_version_template_to_label("//src/stirling/testing/demo_apps/go_grpc_tls_pl/server:golang_%s_grpc_tls_server.tar", sdk_version),
        ],
        deps = ["//src/common/testing/test_utils:cc_library"],
    )
    for sdk_version in pl_all_supported_go_sdk_versions
]

[
    pl_cc_test_library(
        name = pl_go_sdk_version_template_to_label("go_%s_tls_client_container", sdk_version),
        srcs = [],
        hdrs = [pl_go_sdk_version_template_to_label("go_%s_tls_client_container.h", sdk_version)],
        data = [
            pl_go_sdk_version_template_to_label("//src/stirling/testing/demo_apps/go_https/client:golang_%s_https_client.tar", sdk_version),
        ],
        deps = ["//src/common/testing/test_utils:cc_library"],
    )
    for sdk_version in pl_all_supported_go_sdk_versions
]

[
    pl_cc_test_library(
        name = pl_go_sdk_version_template_to_label("go_%s_tls_server_container", sdk_version),
        srcs = [],
        hdrs = [pl_go_sdk_version_template_to_label("go_%s_tls_server_container.h", sdk_version)],
        data = [
            pl_go_sdk_version_template_to_label("//src/stirling/testing/demo_apps/go_https/server:golang_%s_https_server.tar", sdk_version),
        ],
        deps = ["//src/common/testing/test_utils:cc_library"],
    )
    for sdk_version in pl_all_supported_go_sdk_versions
]

pl_cc_test_library(
    name = "golang_sqlx_container",
    srcs = [],
    hdrs = ["golang_sqlx_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers/pgsql:demo_client_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "kafka_container",
    srcs = [],
    hdrs = ["kafka_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:kafka_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "mysql_container",
    srcs = [],
    hdrs = ["mysql_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:mysql_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "nats_client_container",
    srcs = [],
    hdrs = ["nats_client_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/protocols/nats/testing:nats_test_client_with_ca_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "nats_server_container",
    srcs = [],
    hdrs = ["nats_server_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:nats_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "nginx_openssl_1_1_0_container",
    srcs = [],
    hdrs = [
        "nginx_openssl_1_1_0_container.h",
        "nginx_worker_pid.h",
    ],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:nginx_openssl_1_1_0_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "nginx_openssl_1_1_1_container",
    srcs = [],
    hdrs = [
        "nginx_openssl_1_1_1_container.h",
        "nginx_worker_pid.h",
    ],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:nginx_openssl_1_1_1_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "nginx_openssl_3_0_8_container",
    srcs = [],
    hdrs = [
        "nginx_openssl_3_0_8_container.h",
        "nginx_worker_pid.h",
    ],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:nginx_alpine_openssl_3_0_8_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "node_12_3_1_container",
    srcs = [],
    hdrs = ["node_12_3_1_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:node_12_3_1_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "node_14_18_1_alpine_container",
    srcs = [],
    hdrs = ["node_14_18_1_alpine_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:node_14_18_1_alpine_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "node_client_container",
    srcs = [],
    hdrs = ["node_client_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:node_14_18_1_alpine_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "postgresql_container",
    srcs = [],
    hdrs = ["postgresql_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:postgres_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "product_catalog_client_container",
    srcs = [],
    hdrs = ["product_catalog_client_container.h"],
    data = [
        "//src/stirling/testing/demo_apps/hipster_shop/productcatalogservice_client:productcatalogservice_client_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "product_catalog_service_container",
    srcs = [],
    hdrs = ["product_catalog_service_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:productcatalogservice_v0_2_0.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "py_grpc_hello_world_container",
    srcs = [],
    hdrs = ["py_grpc_hello_world_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:py_grpc_helloworld_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "python_3_10_container",
    srcs = [],
    hdrs = ["python_3_10_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers/ssl:python_min_310_https_server.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "python_mysql_connector_container",
    srcs = [],
    hdrs = ["python_mysql_connector_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:mysql_connector_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "rabbitmq_consumer_container",
    srcs = [],
    hdrs = ["rabbitmq_consumer_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers/amqp:consumer_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "rabbitmq_container",
    srcs = [],
    hdrs = ["rabbitmq_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:amqp_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "rabbitmq_producer_container",
    srcs = [],
    hdrs = ["rabbitmq_producer_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers/amqp:producer_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "redis_client_container",
    srcs = [],
    hdrs = ["redis_client_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:redis_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "redis_container",
    srcs = [],
    hdrs = ["redis_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:redis_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "ruby_container",
    srcs = [],
    hdrs = ["ruby_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:ruby_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "thrift_mux_server_container",
    srcs = [],
    hdrs = ["thrift_mux_server_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers/thriftmux:server_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)

pl_cc_test_library(
    name = "zookeeper_container",
    srcs = [],
    hdrs = ["zookeeper_container.h"],
    data = [
        "//src/stirling/source_connectors/socket_tracer/testing/containers:zookeeper_image.tar",
    ],
    deps = ["//src/common/testing/test_utils:cc_library"],
)
